<template>
 <div class="graphitizing">
   <div class="card-table">
      <!-- <el-dialog title="上传" :modal-append-to-body="false" width="400px" :visible.sync="dialogUpload">
        <el-upload
          class="upload-demo"
          drag
          action="https://jsonplaceholder.typicode.com/posts/"
          multiple>
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div class="el-upload__tip" slot="tip">只能上传excle文件，且不超过500kb</div>
        </el-upload>
      </el-dialog> -->
      <el-button type="primary" icon="el-icon-document-add" @click="inStove()">新增</el-button>
        <el-table :header-cell-style="getRowClass" :data="tableData" style="width: 100%">
          <el-table-column label="工单编号" align="center" width="105">
            <template slot-scope="{row}">
              <span>{{row.code}}</span>
            </template>
          </el-table-column>
          <el-table-column label="外协负责人" align="center" width="105">
            <template slot-scope="{row}">
              <span>{{row.outHelpPrincipal}}</span>
            </template>
          </el-table-column>
          <el-table-column label="炉号" align="center">
            <template slot-scope="{row}">
              <span>{{row.stoveCode}}</span>
            </template>
          </el-table-column>
          <el-table-column label="装炉报告日期" align="center" width="105">
            <template slot-scope="{row}">
              <span>{{row.stoveTime}}</span>
            </template>
          </el-table-column>
          <el-table-column label="总数量(支)" align="center">
            <template slot-scope="{row}">
              <span>{{row.totalNumber}}</span>
            </template>
          </el-table-column>
          <el-table-column label="质检人" align="center">
            <template slot-scope="{row}">
              <span>{{row.qualityTestMan}}</span>
            </template>
          </el-table-column>
          <el-table-column label="保管员" align="center">
            <template slot-scope="{row}">
              <span>{{row.storekeeper}}</span>
            </template>
          </el-table-column>
          <el-table-column label="总重" align="center">
            <template slot-scope="{row}">
              <span>{{row.totalWeight}}</span>
            </template>
          </el-table-column>
          <el-table-column label="装炉人" align="center">
            <template slot-scope="{row}">
              <span>{{row.stoveMan}}</span>
            </template>
          </el-table-column>
          <el-table-column label="送电时间" align="center" width="105">
            <template slot-scope="{row}">
              <span>{{row.electric.startElectricTime}}</span>
            </template>
          </el-table-column>
          <el-table-column label="停电时间" align="center" width="105">
            <template slot-scope="{row}">
              <span>{{row.electric.stopElectricTime}}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="250">
            <template slot-scope="{row}">
              <div class="tablebBtn">
                <el-button v-if="!row.isOutStove" @click="goEXCL(row,true)" size="small" type="primary">编辑</el-button>
                <el-button v-if="!row.isOutStove" @click="goEXCL(row,true,true)" size="small" type="primary" plain>出炉</el-button>
                <el-button v-else type="primary" @click="goEXCL(row,'','',true)">查看工单</el-button>
                <el-button @click="deleteOne(row._id)" size="small" type="danger">删除</el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
   </div>
 </div>
</template>

<script>
import { graphiteReportGet, graphiteReportDelete } from '@/api/process.js'
import { nomalPages } from '@/mixin'
export default {
  name: '',
  components: {},
  mixins: [nomalPages],
  data () {
    return {
      dialogUpload: false,
      uploading: false,
      tableData: []
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    inStove () {
      this.$router.push('/grapInstove')
    },
    getAllData () {
      const params = {
        pageSize: this.pageSize,
        currPage: this.currentPage
      }
      graphiteReportGet(params).then(res => {
        console.log(res)
        if (res.data.code === 200) {
          this.tableData = res.data.data.pageData
          this.total = res.data.data.total
        }
      })
    },
    deleteOne (_id) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        graphiteReportDelete(_id).then(res => {
          if (res.data.code === 200) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.getAllData()
          } else {
            this.$message({
              type: 'warging',
              message: res.data.message
            })
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    goEXCL (row, edit, outStove, detial) {
      const data = JSON.stringify(row)
      this.$router.push({
        name: 'grapInstove',
        query: {
          row: data,
          edit: edit,
          outStove: outStove,
          detial: detial
        }
      })
    }
  }
}
</script>

<style  scoped>
.card-search{
  padding-bottom: 10px;
}
.tablebBtn .el-button{
  padding: 8px 14px;
}
</style>
